Overview
Phase 3 is the critical synthesis stage where all data from Phase 1 and Phase 2 is merged into a single unified JSON structure. This phase runs a single script that produces the baseall_stocks_fundamental_analysis.json file.
Execution Order
Phase 3 runs one critical script:Script: bulk_market_analyzer.py
Purpose
Merges data from multiple sources to create the base JSON with 86 fields per stock across 2,775 stocks.Input Files
Data Merging Process
The script iterates through all stocks and merges data sections:Output Files
| File | Description | Size | Records |
|---|---|---|---|
all_stocks_fundamental_analysis.json | Base master JSON | ~45 MB | 2,775 |
Output Structure
Data Processing Steps
Step 1: Load All Data Sources
Step 2: Extract Quarterly Fundamentals
Step 3: Merge Technical Indicators
Step 4: Build Unified Record
Step 5: Save Output
Field Calculation Examples
Quarterly Changes (QoQ, YoY)
Pipe String Parsing
SMA/EMA Status Formatting
Dependencies
Required from Phase 1
fundamental_data.json(CRITICAL)master_isin_map.json(for iteration)dhan_data_response.json(for technical data)nse_equity_list.csv(for listing dates)
Required from Phase 2
advanced_indicator_data.json(for SMA/EMA/Pivot)
Optional (Soft Dependencies)
- If any file is missing, the script continues but fields will be empty/0
Typical Execution Time
~30-60 seconds — Pure in-memory data merging (no API calls)
Performance Breakdown
- Load all JSONs: ~5s
- Iterate 2,775 stocks: ~20s
- Write output JSON: ~10s
Error Handling
Critical Failure Detection
Non-Critical Missing Files
Output Validation
File Size Check
Record Count Check
Field Completeness Check
What Phase 3 Does NOT Include
The base JSON does NOT include the following (populated in Phase 4):Phase 3 Output Summary
Files Produced
Field Coverage
- Complete: 60 fields (fundamentals, technicals, ratios, returns)
- Placeholders: 26 fields (to be populated in Phase 4)
Next Phase
Once Phase 3 completes, the pipeline proceeds to:Phase 4: Enrichment Injection
Modifies the master JSON in-place to inject advanced metrics, F&O data, earnings performance, and event markers. Order matters!